#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;
typedef unsigned long long ull;
typedef long double ldb;

#define in read()
#define pii pair<int,int>
#define fi first
#define se second
#define FILE(x) freopen(x".in","r",stdin);\
	freopen(x".out","w",stdout);
#define pb push_back
#define vec vector<int>

int read(){int x = 0,sgn = 1;char ch = getchar();for(;!isdigit(ch);ch = getchar()) if(ch == '-') sgn = -1;for(;isdigit(ch);ch = getchar()) x = (x<<1)+(x<<3)+(ch^48);return x*sgn;}

const int N = 1e6+10;

int mx[N],n;
char s[N];

int main (){
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
	n = in;scanf("%s",s + 1); mx[n + 1] = 0;
	for(int i = n;i >= 1;i--) mx[i] = max(mx[i + 1],(int)s[i]);
	for(int i = n;i >= 1;i--){
		if(mx[i] > s[i]){
			int ps = n;
			for(int j = n;j > i;j--) if(s[j] > s[i]) {ps = j;break;}
			printf("%d %d\n",i,ps); return 0;
		}
	}
	puts("-1");
	return 0;
}
